<?php
include('include/config.inc.php');
if(!isset($_SESSION['s_activId'.$cfgPack])
  || (isset($_SESSION['s_userType'.$cfgPack]) && isset($cfgFileNames['paryViewAj'][$_SESSION['s_userType'.$cfgPack]]) 
      && $cfgFileNames['paryViewAj'][$_SESSION['s_userType'.$cfgPack]] == 0))
{
  $_SESSION['s_urlRedirectDir'] = $_SERVER['REQUEST_URI'];
  header("Location:checkLogin.php");
}
else
{	
  $partyItemDetailArray = array();
  $partyId              = isset($_REQUEST['partyId']) ? $_REQUEST['partyId'] : 0;
  $branchId              = isset($_REQUEST['branchId']) ? $_REQUEST['branchId'] : 0;
  $selectParty = "SELECT party.partyId,party.companyName,party.contactPerson1,party.contactPerson2,party.contactPerson3,party.phoneNo,
                         party.branchId,party.address,party.city,party.mobile1,party.mobile2,party.mobile3,party.email
                    FROM party";
  if($partyId > 0)
  {
  	$selectParty .= " WHERE party.partyId = ".$partyId." ";
  }
  else if($branchId > 0)
  {
  	$selectParty .= " WHERE party.branchId = ".$branchId." ";
  }
  else
  {
    $selectParty .= " ORDER BY companyName";
  }
  $selectpartyResult = mysql_query($selectParty);
  $i = 0;
  while($partyRow = mysql_fetch_array($selectpartyResult))
  {
    $partyItemDetailArray[$i]['partyId']        = $partyRow['partyId'];
    $partyItemDetailArray[$i]['companyName']    = $partyRow['companyName'];
    $partyItemDetailArray[$i]['contactPerson1'] = $partyRow['contactPerson1'];
    $partyItemDetailArray[$i]['contactPerson2'] = $partyRow['contactPerson2'];
    $partyItemDetailArray[$i]['contactPerson3'] = $partyRow['contactPerson3'];
    $partyItemDetailArray[$i]['phoneNo']        = $partyRow['phoneNo'];
    $partyItemDetailArray[$i]['address']    		= $partyRow['address'];
    $partyItemDetailArray[$i]['city']       		= $partyRow['city'];
    $partyItemDetailArray[$i]['mobile1']    		= $partyRow['mobile1'];
    $partyItemDetailArray[$i]['mobile2']    		= $partyRow['mobile2'];
    $partyItemDetailArray[$i]['mobile3']    		= $partyRow['mobile3'];
    $partyItemDetailArray[$i]['email']      		= $partyRow['email'];
    $i++;
  }
  include("./bottom.php");
  $smarty->assign("partyItemDetailArray",$partyItemDetailArray);
  $smarty->display("paryViewAj.tpl");
  } 
?>